<% layout('/layouts/default.html', {title: '审核问题', libs:['fileupload','validate']}){ %>
<div class="main-content">
	<div class="box box-main">
	    <div class="box-header">
			<div class="box-title">
				<i class="fa icon-trophy"></i> ${text('审核问题')}
			</div>
			<div class="box-tools pull-right">
				<button type="button" class="btn btn-box-tool"
					data-widget="collapse">
					<i class="fa fa-minus"></i>
				</button>
			</div>
		</div> 
		<%
		 var question= @com.jeesite.modules.suggestion.util.Get.getQuestion(taskId);
	    %> 
	    <% include('/modules/suggestion/questionInfo.html',{question:question}){}  %>	
	    <#form:form id="inputForm" model="${question}" action="${ctx}/suggestion/question/save" method="post" class="form-horizontal">
			<#form:hidden path="questionCode"/>
			<#form:hidden name="taskId" value="${taskId}"/>
			<div class="box-body">
				<div class="form-unit">${text('审核信息')}</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required hide"></span> ${text('不通过理由')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:textarea id="rejectMsg" path="rejectMsg" rows="4" maxlength="500" class="form-control "/>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="box-footer">
				<div class="row">
					<div class="col-sm-offset-2 col-sm-10">
						<button type="submit" onclick="$('#inputForm').attr('action','${ctx}/suggestion/question/auditPass')" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> ${text('审核通过')}</button>&nbsp;
						<button type="submit" class="btn btn-sm btn-danger" id="btnSubmitToAudit"><i class="fa fa-check"></i> ${text('审核驳回')}</button>&nbsp;
						<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
					</div>
				</div>
			</div>
		</#form:form>
	</div>
</div>
<% } %>
<script>	
	$("#btnSubmitToAudit").click(function(){
		var rejectText = $("#rejectMsg").val();
		if(rejectText==null||rejectText==""){
			js.showErrorMessage("请填写驳回理由");
			return false;
		}else{
			$('#inputForm').attr('action','${ctx}/suggestion/question/auditReject');
			return true;
		}
	})
	$("#inputForm").validate({
		submitHandler : function(form) {
			js.ajaxSubmitForm($(form), function(data) {
				js.showMessage(data.message);
				if (data.result == Global.TRUE) {
					js.closeCurrentTabPage(function(contentWindow) {
						contentWindow.page();
					});
				}
			}, "json");
		}
	});
</script>
